#ifndef PSD_IO_MX_H
#define PSD_IO_MX_H

#include <sys/socket.h>
#include <pthread.h>

#include "psd_conn.h"
#include "myriexpress.h"

typedef struct psd_mx_header_t {
  uint32_t type;
  uint32_t args;
} psdmxHeader;

#define MX_TYPE_DATA	1
#define MX_TYPE_CLOSE	2

typedef struct psd_connection_mx_data_t {
  pthread_mutex_t lock;
  int closed;
  mx_endpoint_t endpoint;
  mx_endpoint_addr_t ep_addr; 
  uint32_t filter;
  uint32_t rem_ep_id;  
  int read_closed;
  int write_closed;
  uint32_t left_to_read;
  uint32_t left_to_write;
  psdmxHeader *hdr_bufs;
  int hdr_bufs_head;
  int session_established;
  int close_msg_received;
} psdConn_mxData;

psdConn *psd_conn_mx_alloc(mx_endpoint_t endpoint,mx_endpoint_addr_t ep_addr);

#endif
